package com.hyt.it.ogt.kq.service.bm.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hyt.it.ogt.kq.service.bm.model.entity.StudentSubject;
import com.hyt.it.ogt.kq.service.bm.model.vo.PayStatVo;
import com.hyt.it.ogt.kq.service.bm.model.vo.ProjectStatVo;
import com.hyt.it.ogt.kq.service.bm.model.vo.StudentStatVo;
import com.hyt.it.ogt.kq.service.bm.model.vo.StudentSubjectExportVo;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Optional;

/**
 * <p>
 * 考生报名科目表 Mapper 接口
 * </p>
 *
 * @author wangt
 * @since 2020-05-15
 */
public interface StudentSubjectMapper extends BaseMapper<StudentSubject> {

    List<StudentSubject> getStudentSbjects(
            @Param("projectId") String projectId,
            @Param("studentId") String studentId);

    StudentSubject getStudentSbject(
            @Param("studentId") String studentId,
            @Param("subjectId") String subjectId,
            @Param("projectId") String projectId);

    List<StudentSubject> getStudentSubjectList(
            @Param("enrollId") String enrollId,
            @Param("subjectId") String subjectId,
            @Param("ids") List<String> studentIds,
            @Param("payState") String payState,
            @Param("kwFlag") String kwFlag);

    void updateKwflag(@Param("subjectId") String subjectId,
                      @Param("projectId") String projectId,
                      @Param("kwFlag") String kwFlag);

    void updateStudentFlag(@Param("studentId") String studentId,
                           @Param("projectId") String projectId,
                           @Param("subjectId") String subjectId);

    List<StudentSubject> getStuSubjectsByOrderIdAndOrderRefundStatus(
            @Param("bmOrderId") String bmOrderId,
            @Param("refundStatus") Integer refundStatus);

    List<StudentSubject> getStuSubjectsByOrderIdAndSubjectIds(
            @Param("bmOrderId") String bmOrderId,
            @Param("subjectIds") List<String> subjectIds);

    List<StudentSubject> getStuSubjectsByOrderIdAndOrderPayStatus(
            @Param("bmOrderId") String bmOrderId,
            @Param("payStatus") Integer payStatus);

    List<StudentStatVo> statByExamId(@Param("examId") String examId);

    List<StudentStatVo> statByStudentId(@Param("projectId") String projectId);


    List<PayStatVo> statPayByProjectId(@Param("projectId") String projectId, @Param("permissionList") List<String> permissionList, @Param("deptId") String deptId);

    List<StudentSubject> queryStudentSubject(
            @Param("isAudit") String isAudit,
            @Param("isPay") String isPay,
            @Param("subjectId") String subjectId,
            @Param("studentId") String studentId,
            @Param("permissionList") List<String> permissionList,
            @Param("projectId") String projectId);

    void updateStudentSubjectAudit(@Param("projectId") String projectId, @Param("studentId") String studentId, @Param("isAudit") Integer isAudit);

    List<StudentSubject> queryRegSubject(@Param("regId") String regId, @Param("projectId") String projectId);

    StudentSubject getStudentSubjectById(@Param("id") String id);

    List<StudentSubject> getStudentSubjectByIds(@Param("ids") List<String> ids);

    ProjectStatVo queryProjectApplyNum(@Param("projectId") String projectId, @Param("deptId") String deptId);

    List<StudentSubject> queryUnpaySubjectStudent(@Param("studentId") String studentId);

    /**
     * 统计项目下面报考科目的数量
     *
     * @param projectId
     * @param subjectId
     * @return
     */
    Integer countStudentSubject(@Param("projectId") String projectId, @Param("subjectId") String subjectId);

    /**
     * 获取区域下已报名人次
     *
     * @param projectId         报名ID
     * @param areaCollectInfoId 区域采集字段ID
     * @param areaCode          区域code
     * @param deptId
     * @return
     */
    Optional<Integer> countAreaPersonTimeNum(@Param("projectId") String projectId, @Param("areaCollectInfoId") String areaCollectInfoId, @Param("areaCode") String areaCode, @Param("deptId") String deptId);


    /***
     * 分页查询考生列表
     * @param pageParam
     * @param permissionList
     * @param param
     * @return
     */
    List<StudentSubjectExportVo> getStudentSubjectNamesList(@Param("projectId") String projectId);

    /**
     * 获取已报名人次
     *
     * @param projectId 报名ID
     * @param deptId    部门ID
     * @return
     */
    Optional<Integer> countPersonTimeNum(@Param("projectId") String projectId, @Param("deptId") String deptId);
}
